package com.eascs.web.api.view.method;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;

import com.eascs.web.api.ApiMethodInvokeObject;
import com.eascs.web.api.util.ApiMethodInvokeObjectContext;

public class ApiMethodInvokeObjectSimpleViewContext {
	public static List<ApiMethodInvokeObjectSimpleView> listApiMethodInvokeObjectView() {
		List<ApiMethodInvokeObjectSimpleView> result = new ArrayList<>();
		List<ApiMethodInvokeObject> apiMethodInvokeObjects = new ArrayList<>();
		Map<String, ApiMethodInvokeObject> methodInvokeObjectMap = ApiMethodInvokeObjectContext.getMethodInvokeObjectMap();
		apiMethodInvokeObjects.addAll(methodInvokeObjectMap.values());
		apiMethodInvokeObjects.sort(new Comparator<ApiMethodInvokeObject>() {
			@Override
			public int compare(ApiMethodInvokeObject o1, ApiMethodInvokeObject o2) {
				return o1.getApiMethod().name().compareTo(o2.getApiMethod().name());
			}
		});
		for (ApiMethodInvokeObject apiMethodInvokeObject : apiMethodInvokeObjects) {
			result.add(new ApiMethodInvokeObjectSimpleView(apiMethodInvokeObject));
		}
		return result;
	}
}
